package com.heima.wemedia.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.heima.common.exception.CustException;
import com.heima.feigns.ArticleFeign;
import com.heima.feigns.UserFeign;
import com.heima.model.article.pojos.ApAuthor;
import com.heima.model.article.vos.SearchArticleVO;
import com.heima.model.comment.dtos.FansFollowDTO;
import com.heima.model.common.constants.user.UserRelationConstants;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.mess.app.NewBehaviorDTO;
import com.heima.model.threadlocal.WmThreadLocalUtils;
import com.heima.model.user.pojos.ApUser;
import com.heima.model.wemedia.dtos.UserFansPortDTO;
import com.heima.model.wemedia.dtos.WmStatisticsDTO;
import com.heima.model.wemedia.pojos.WmStatistics;
import com.heima.model.wemedia.pojos.WmUser;
import com.heima.model.wemedia.vos.*;
import com.heima.wemedia.service.WmStatisticsService;
import com.heima.wemedia.service.WmUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.data.redis.core.script.DefaultRedisScript;
import org.springframework.scripting.support.ResourceScriptSource;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;

@Service
@Slf4j
public class WmStatisticsServiceImpl implements WmStatisticsService {
    @Autowired
    private ArticleFeign articleFeign;
    @Autowired
    private MongoTemplate mongoTemplate;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    WmUserService wmUserService;
    @Autowired
    UserFeign userFeign;

    //自媒体数据统计方法
    @Override
    public void statisticsBehavior(List<NewBehaviorDTO> behaviorList) {
        //获取所有行为的文章id并过滤去重,然后获取作者id集合
        behaviorList.stream().map(behavior -> {
            return behavior.getArticleId();
        }).distinct().map(articleId -> {
            ResponseResult<SearchArticleVO> articleResp = articleFeign.findArticle(articleId);
            if (articleResp.checkCode()) {
                Long authorId = articleResp.getData().getAuthorId();
                //根据作者id查询WmUser
                LambdaQueryWrapper<WmUser> query = Wrappers.lambdaQuery();
                query.eq(WmUser::getApAuthorId, authorId);
                return wmUserService.getOne(query);
            }
            return null;
        }).filter(a -> {
            return a != null;
        }).forEach(user -> {
            Integer wmUserId = user.getId();
            ResponseResult<ApAuthor> ApAuthorResp = articleFeign.findByWmUserId(wmUserId);
            //获取作者id
            Integer authorId = ApAuthorResp.getData().getId();
            //从redis拉取文章发布行为数据
            List<String> userIds = new ArrayList<>();
            try {
                //调用lua脚本并执行
                DefaultRedisScript<List> redisScript = new DefaultRedisScript<>();
                // 设置脚本的返回结果
                redisScript.setResultType(List.class);
                //lua文件存放在resources目录下的redis文件夹内
                redisScript.setScriptSource(new ResourceScriptSource(new ClassPathResource("redis.lua")));
                // 执行lua脚本
                userIds = redisTemplate.execute(redisScript, Arrays.asList("userIds"));
                //过滤出当前用户发布的文章的数量
                userIds = userIds.stream().filter(id -> {
                    return id.equals(wmUserId);
                }).collect(Collectors.toList());
            } catch (Exception e) {
                e.printStackTrace();
                CustException.cust(AppHttpCodeEnum.SERVER_ERROR, "执行lua脚本失败");
            }
            //创建集合保存过滤后的数据
            ArrayList<NewBehaviorDTO> newBehaviorDTOList = new ArrayList<>();
            //遍历behaviorList,过滤出针对当前用户的文章产生的行为
            for (NewBehaviorDTO newBehaviorDTO : behaviorList) {
                //根据行为对象中的文章id查询文章
                ResponseResult<SearchArticleVO> articleResp = articleFeign.findArticle(newBehaviorDTO.getArticleId());
                if (articleResp.checkCode()) {
                    SearchArticleVO article = articleResp.getData();
                    //如果文章作者id等于当前用户的作者id,保存到集合
                    if (article.getAuthorId().toString().equals(authorId.toString())) {
                        newBehaviorDTOList.add(newBehaviorDTO);
                    }
                }
            }
            //遍历过滤后的行为集合
            Optional<WmStatistics> reduce = newBehaviorDTOList.stream().map(behavior -> {
                WmStatistics wmStatistics = new WmStatistics();
                wmStatistics.setUserId(wmUserId);
                wmStatistics.setCreateTime(LocalDate.now().toString());
                //创建行为数据统计分析聚合对象
                switch (behavior.getType()) {
                    case LIKES:
                        wmStatistics.setLikes(behavior.getAdd());
                        break;
                    case UNLIKES:
                        wmStatistics.setUnlikes(behavior.getAdd());
                        break;
                    case FOLLOW:
                        wmStatistics.setFollow(behavior.getAdd());
                        break;
                    case UNFOLLOW:
                        wmStatistics.setUnfollow(behavior.getAdd());
                        break;
                    case VIEWS:
                        //判断是否是文章作者的粉丝,根据articleId查询文章
                        ResponseResult<SearchArticleVO> articleResp = articleFeign.findArticle(behavior.getArticleId());
                        //校验响应
                        if (!articleResp.checkCode()) {
                            log.info("当前文章不存在!");
                            break;
                        }
                        wmStatistics.setReadCount(behavior.getAdd());
                        //根据用户id查询redis
                        ZSetOperations zsetOption = redisTemplate.opsForZSet();
                        Double score = zsetOption.score(UserRelationConstants.FOLLOW_LIST + behavior.getUserId(), String.valueOf(articleResp.getData().getAuthorId()));
                        if (score != null) {
                            //已经关注,粉丝阅读数+1
                            wmStatistics.setReadFansCount(behavior.getAdd());
                        }
                        break;
                    case COMMENT:
                        wmStatistics.setComment(behavior.getAdd());
                        break;
                    case COLLECTION:
                        wmStatistics.setCollection(behavior.getAdd());
                        break;
                    default:
                }
                return wmStatistics;
            }).reduce((a1, a2) -> {
                a1.setLikes(a1.getLikes() + a2.getLikes());
                a1.setUnlikes(a1.getUnlikes() + a2.getUnlikes());
                a1.setComment(a1.getComment() + a2.getComment());
                a1.setFollow(a1.getFollow() + a2.getFollow());
                a1.setUnfollow(a1.getUnfollow() + a2.getUnfollow());
                a1.setCollection(a1.getCollection() + a2.getCollection());
                a1.setReadCount(a1.getReadCount() + a2.getReadCount());
                a1.setReadFansCount(a1.getReadFansCount() + a2.getReadFansCount());
                return a1;
            });
            //判断结果
            if (reduce.isPresent()) {
                WmStatistics wmStatistics1 = reduce.get();
                //根据文章id查询今日的行为数据
                Query query = Query.query(Criteria.where("userId").is(wmUserId).and("createTime").is(LocalDate.now().toString()));
                WmStatistics wmStatistics = mongoTemplate.findOne(query, WmStatistics.class);
                if (wmStatistics == null) {
                    mongoTemplate.save(wmStatistics1);
                }
                wmStatistics.setReadCount(wmStatistics.getReadCount() + wmStatistics1.getReadCount());
                wmStatistics.setReadFansCount(wmStatistics.getReadFansCount() + wmStatistics1.getReadFansCount());
                wmStatistics.setComment(wmStatistics.getComment() + wmStatistics1.getComment());
                wmStatistics.setFollow(wmStatistics.getFollow() + wmStatistics1.getFollow());
                wmStatistics.setCollection(wmStatistics.getCollection() + wmStatistics1.getCollection());
                wmStatistics.setForward(wmStatistics.getForward() + wmStatistics1.getForward());
                wmStatistics.setLikes(wmStatistics.getLikes() + wmStatistics1.getLikes());
                wmStatistics.setUnlikes(wmStatistics.getUnlikes() + wmStatistics1.getUnlikes());
                wmStatistics.setUnfollow(wmStatistics.getUnfollow() + wmStatistics1.getUnfollow());
                wmStatistics.setArticle(wmStatistics.getArticle() + userIds.size());
                //将WmStatistics存储到mongodb
                mongoTemplate.save(wmStatistics);
            }
        });
    }

    //自媒体平台统计分析
    @Override
    public ResponseResult statisticsNews(WmStatisticsDTO dto) {
        //参数校验
        if (dto.getEtime() == null || dto.getStime() == null) {
            //默认显示30天数据
            long nowTime = System.currentTimeMillis();
            dto.setStime(nowTime - Long.valueOf((30 * 24 * 60 * 60L + "000")));
            dto.setEtime(nowTime);
        }
        //获取时间毫秒值转换成日期字符串
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String sTime = sdf.format(new Date(dto.getStime()));
        String eTime = sdf.format(new Date(dto.getEtime()));
        //获取当前登录用户id
        Integer wmUserId = WmThreadLocalUtils.getUser().getId();
        //根据wmUserId查询mongo获取统计数据
        Query query = Query.query(Criteria.where("userId").is(wmUserId).and("createTime").gte(sTime).lte(eTime));
        List<WmStatistics> wmStatistics = mongoTemplate.find(query, WmStatistics.class);
        //创建对象
        WmStatisticsVo wmStatisticsVo = new WmStatisticsVo();
        List<TableDataVo> tableData = new ArrayList<>();
        TopItemsVo topItemsVo = new TopItemsVo();
        //遍历集合
        for (WmStatistics wmStatistic : wmStatistics) {
            //TableDataVo
            TableDataVo tableDataVo = new TableDataVo();
            tableDataVo.setDate(wmStatistic.getCreateTime());
            tableDataVo.setReadNum(wmStatistic.getReadCount());
            tableDataVo.setFanReadNum(wmStatistic.getReadFansCount());
            tableDataVo.setCommentNum(wmStatistic.getComment());
            tableDataVo.setFavNum(wmStatistic.getCollection());
            tableDataVo.setForwardNum(10086);
            tableData.add(tableDataVo);
            //TopItemsVo
            topItemsVo.setArticleNum(topItemsVo.getArticleNum() + wmStatistic.getArticle());
            topItemsVo.setReadNum(topItemsVo.getReadNum() + wmStatistic.getReadCount());
            topItemsVo.setFanReadNum(topItemsVo.getFanReadNum() + wmStatistic.getReadFansCount());
            topItemsVo.setCommentNum(topItemsVo.getCommentNum() + wmStatistic.getComment());
        }
        //封装ChartDataVo
        ChartDataVo chartDataVo = new ChartDataVo();
        //创建ChartDataVo内部集合
        ArrayList<ChartDataVoVo> chartDataVolist = new ArrayList<>();
        //创建集合内部参数并封装
        ChartDataVoVo chartDataVoVo1 = new ChartDataVoVo();
        ChartDataVoVo chartDataVoVo2 = new ChartDataVoVo();
        ChartDataVoVo chartDataVoVo3 = new ChartDataVoVo();
        ChartDataVoVo chartDataVoVo4 = new ChartDataVoVo();
        chartDataVoVo1.setValue(topItemsVo.getArticleNum());
        chartDataVoVo1.setName("文章量");
        chartDataVolist.add(chartDataVoVo1);
        chartDataVoVo2.setValue(topItemsVo.getReadNum());
        chartDataVoVo2.setName("阅读量");
        chartDataVolist.add(chartDataVoVo2);
        chartDataVoVo3.setValue(topItemsVo.getFanReadNum());
        chartDataVoVo3.setName("粉丝阅读量");
        chartDataVolist.add(chartDataVoVo3);
        chartDataVoVo4.setValue(topItemsVo.getCommentNum());
        chartDataVoVo4.setName("评论量");
        //将chartDataVoVo放到集合中
        chartDataVolist.add(chartDataVoVo4);
        chartDataVo.setData(chartDataVolist);
        //对tableData排序
        tableData = tableData.stream().sorted((a1, a2) -> {
            int date1 = Integer.parseInt(a1.getDate().replace("-", ""));
            int date2 = Integer.parseInt(a2.getDate().replace("-", ""));
            return date2 - date1;
        }).collect(Collectors.toList());
        //封装返回数据
        wmStatisticsVo.setTableData(tableData);
        wmStatisticsVo.setTopItems(topItemsVo);
        wmStatisticsVo.setChartData(chartDataVo);
        //返回结果
        return ResponseResult.okResult(wmStatisticsVo);
    }

    //粉丝概况
    @Override
    public ResponseResult fans(WmStatisticsDTO dto) {
        //参数校验
        if (dto.getEtime() == null || dto.getStime() == null) {
            //默认显示30天数据
            long nowTime = System.currentTimeMillis();
            dto.setStime(nowTime - Long.valueOf((30 * 24 * 60 * 60L + "000")));
            dto.setEtime(nowTime);
        }
        //获取时间毫秒值转换成日期字符串
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String sime = sdf.format(new Date(dto.getStime()));
        String etime = sdf.format(new Date(dto.getEtime()));
        //获取当前登录用户
        Integer userId = WmThreadLocalUtils.getUser().getId();
        if (userId == null) {
            CustException.cust(AppHttpCodeEnum.NEED_LOGIN);
        }
        //根据userId查询WmUser表
        WmUser wmUser = wmUserService.getById(userId);
        if (wmUser == null) {
            CustException.cust(AppHttpCodeEnum.DATA_NOT_EXIST, "当前用户不存在!");
        }
        Integer wmUserId = wmUser.getId();
        //根据wmUserId查询mongo获取统计数据
        Query query = Query.query(Criteria.where("userId").is(wmUserId).and("createTime").gte(sime).lte(etime));
        List<WmStatistics> wmStatistics = mongoTemplate.find(query, WmStatistics.class);
        //遍历集合 创建粉丝详情对象
        FansStatisticsVo fansStatisticsVo = new FansStatisticsVo();
        fansStatisticsVo.setUserId(wmUserId + "");
        //创建集合,保存WmStatistics对象
        ArrayList<FansStatisticsVo> list = new ArrayList<>();
        for (WmStatistics wmStatistic : wmStatistics) {
            fansStatisticsVo.setArticle(fansStatisticsVo.getArticle() + wmStatistic.getArticle());
            fansStatisticsVo.setRead_count(fansStatisticsVo.getRead_count() + wmStatistic.getReadCount());
            fansStatisticsVo.setComment(fansStatisticsVo.getComment() + wmStatistic.getComment());
            fansStatisticsVo.setCollection(fansStatisticsVo.getCollection() + wmStatistic.getCollection());
            fansStatisticsVo.setLikes(fansStatisticsVo.getLikes() + wmStatistic.getLikes());
            fansStatisticsVo.setFollow(fansStatisticsVo.getFollow() + wmStatistic.getFollow());
            fansStatisticsVo.setUnlikes(fansStatisticsVo.getUnlikes() + wmStatistic.getUnlikes());
            fansStatisticsVo.setCreated_time(new Date());
            list.add(fansStatisticsVo);
        }
        return ResponseResult.okResult(list);
    }

    //粉丝画像
    @Override
    public ResponseResult userFans() {
        //获取当前登录用户
        WmUser user = WmThreadLocalUtils.getUser();
        if (user == null) {
            CustException.cust(AppHttpCodeEnum.NEED_LOGIN);
        }
        Integer userId = user.getId();
        //根据userId查询WmUser表
        WmUser wmUser = wmUserService.getById(userId);
        if (wmUser == null) {
            CustException.cust(AppHttpCodeEnum.DATA_NOT_EXIST, "wmUser用户不存在!");
        }
        Set<String> range = redisTemplate.opsForZSet().range(UserRelationConstants.FANS_LIST + wmUser.getApUserId(), 0, -1);
        int male = 0;
        int female = 0;
        int age0 = 0;
        int age21 = 0;
        int age31 = 0;
        for (String fansId : range) {
            //根据fansId查询ApUser
            ResponseResult<ApUser> userResp = userFeign.findUserById(Integer.parseInt(fansId));
            if (userResp.checkCode()&&userResp.getData()!=null) {
                ApUser apUser = userResp.getData();
                Boolean sex = apUser.getSex();
                if (sex) {
                    //女性
                    female++;
                } else {
                    male++;
                }
                Integer age = apUser.getAge();
                if (age >= 0 && age <= 20) {
                    age0++;
                } else if (age > 21 && age <= 30) {
                    age21++;
                } else if (age > 31) {
                    age31++;
                }
            }
        }
        //创建粉丝画像对象,性别分布对象-男性
        UserFansVo userFansSexVoMale = new UserFansVo();
        userFansSexVoMale.setUser_Id(wmUser.getApUserId() + "");
        userFansSexVoMale.setName("sex:male");
        userFansSexVoMale.setValue(male);
        userFansSexVoMale.setCreate_time(LocalDate.now().toString());
        //创建集合保存参数
        ArrayList<Object> list = new ArrayList<>();
        list.add(userFansSexVoMale);
        //创建粉丝画像对象,性别分布对象-女性
        UserFansVo userFansSexVoFemale = new UserFansVo();
        BeanUtils.copyProperties(userFansSexVoMale, userFansSexVoFemale);
        userFansSexVoFemale.setName("sex:female");
        userFansSexVoFemale.setValue(female);
        list.add(userFansSexVoFemale);
        //根据apUserId查询ApUser
        ResponseResult<ApUser> userResp = userFeign.findUserById(wmUser.getApUserId());
        //检查参数
        if (!userResp.checkCode()) {
            CustException.cust(AppHttpCodeEnum.DATA_NOT_EXIST, "apUser用户不存在!");
        }
        //创建粉丝画像对象,年龄分布对象-0至20岁
        UserFansVo userFansAgeVo0 = new UserFansVo();
        BeanUtils.copyProperties(userFansSexVoMale, userFansAgeVo0);
        userFansAgeVo0.setName("age:0-20");
        userFansAgeVo0.setValue(age0);
        list.add(userFansAgeVo0);
        //创建粉丝画像对象,年龄分布对象-0至20岁
        UserFansVo userFansAgeVo21 = new UserFansVo();
        BeanUtils.copyProperties(userFansAgeVo0, userFansAgeVo21);
        userFansAgeVo21.setName("age:21-30");
        userFansAgeVo21.setValue(age21);
        list.add(userFansAgeVo21);
        //创建粉丝画像对象,年龄分布对象-0至20岁
        UserFansVo userFansAgeVo31 = new UserFansVo();
        BeanUtils.copyProperties(userFansAgeVo0, userFansAgeVo31);
        userFansAgeVo31.setName("age:31-40");
        userFansAgeVo31.setValue(age31);
        list.add(userFansAgeVo31);
        //根据wmUserId查询mongo获取统计数据
        //查询最近7天的统计数据
        long onedayMill = Long.valueOf(1 * 24 * 60 * 60 + "000");
        long day07Time = System.currentTimeMillis();
        long day01Time = Long.valueOf(7 * 24 * 60 * 60 + "000");
        //获取时间毫秒值转换成日期字符串
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String day01 = sdf.format(new Date(day01Time));
        String day07 = sdf.format(new Date(day07Time));
        Query query = Query.query(Criteria.where("userId").is(wmUser.getId()).and("createTime").gte(day01).lte(day07));
        List<WmStatistics> wmStatistics = mongoTemplate.find(query, WmStatistics.class);
        //将wmStatistics按照日期分组
        for (WmStatistics wmStatistic : wmStatistics) {
            //创建粉丝画像对象,近七日粉丝阅读量
            UserFansVo userFansRead = new UserFansVo();
            BeanUtils.copyProperties(userFansSexVoMale, userFansRead);
            userFansRead.setName("read:" + wmStatistic.getCreateTime());
            userFansRead.setValue(wmStatistic.getReadFansCount());
            userFansRead.setCreate_time(wmStatistic.getCreateTime());
            list.add(userFansRead);
        }
        return ResponseResult.okResult(list);
    }

    //粉丝列表
    @Override
    public ResponseResult list(UserFansPortDTO dto) {
        //获取当前登录用户
        WmUser user = WmThreadLocalUtils.getUser();
        if (user == null) {
            CustException.cust(AppHttpCodeEnum.NEED_LOGIN);
        }
        Integer wmUserId = user.getId();
        //查询WmUser
        user = wmUserService.getById(wmUserId);
        //检查参数
        Integer page = dto.getPage();
        Integer size = dto.getSize();
        if (page == null) {
            page = 0;
        }
        if (size == null || size == 0) {
            size = 10;
        }
        //获取redis中当前用户的所有粉丝数据
        Set<String> range = redisTemplate.opsForZSet().range(UserRelationConstants.FANS_LIST + user.getApUserId(), 0, -1);
        //获取redis中当前用户的所有关注数据
        Set<String> range2 = redisTemplate.opsForZSet().range(UserRelationConstants.FOLLOW_LIST + user.getApUserId(), 0, -1);
        //创建集合保存UserFansListVo对象
        ArrayList<UserFansListVo> list = new ArrayList<>();
        //遍历集合
        for (String fansId : range) {
            //根据fansId查询ApUser
            ResponseResult<ApUser> apUserResp = userFeign.findUserById(Integer.parseInt(fansId));
            if (apUserResp.checkCode() && apUserResp.getData() != null) {
                ApUser apUser = apUserResp.getData();
                //创建UserFansListVo
                UserFansListVo userFansListVo = new UserFansListVo();
                userFansListVo.setFans_name(apUser.getName());
                userFansListVo.setFans_id(fansId);
                boolean flag = false;
                for (String followId : range2) {
                    if (followId.equals(fansId)) {
                        //相互关注了
                        flag = true;
                    }
                }
                userFansListVo.set_follow(flag);
                userFansListVo.setPhoto("www.xxx.jpg");
                list.add(userFansListVo);
            }
        }
        return ResponseResult.okResult(list);
    }

    //粉丝关注
    @Override
    public ResponseResult changeFollowState(FansFollowDTO dto) {
        //获取当前登录用户
        WmUser user = WmThreadLocalUtils.getUser();
        if (user == null) {
            CustException.cust(AppHttpCodeEnum.NEED_LOGIN);
        }
        Integer wmUserId = user.getId();
        //查询WmUser
        user = wmUserService.getById(wmUserId);
        if(user==null){
            CustException.cust(AppHttpCodeEnum.DATA_NOT_EXIST,"当前用户不存在自媒体账户!");
        }
        String fansId = dto.getFansId();
        if (user.getApUserId().toString().equals(fansId)) {
            CustException.cust(AppHttpCodeEnum.DATA_NOT_ALLOW, "自己不能关注自己");
        }
        //判断是否已经关注该用户,从redis中拿数据
        Double score = redisTemplate.opsForZSet().score(UserRelationConstants.FOLLOW_LIST + fansId, user.getApUserId().toString());
        //判断操作类型
        if (dto.getSwitchState()) {
            //关注用户,判断是否已经关注
            if (score != null) {
                CustException.cust(AppHttpCodeEnum.DATA_NOT_ALLOW, "您已经关注该用户!");
            }
            //用户关注作者
            redisTemplate.opsForZSet().add(UserRelationConstants.FOLLOW_LIST +
                    user.getApUserId().toString(), fansId, System.currentTimeMillis());
            //作者关注用户
            redisTemplate.opsForZSet().add(UserRelationConstants.FANS_LIST + fansId, user.getApUserId().toString(), System.currentTimeMillis());
        }
        if (!dto.getSwitchState()) {
            //关注用户,判断是否已经关注
            if (score == null) {
                CustException.cust(AppHttpCodeEnum.DATA_NOT_ALLOW, "您还未关注该用户,无法取消关注!");
            }
            //用户取消关注作者
            redisTemplate.opsForZSet().remove(UserRelationConstants.FOLLOW_LIST+user.getApUserId(), fansId);
            //作者取消关注用户
            redisTemplate.opsForZSet().remove(UserRelationConstants.FANS_LIST + fansId, user.getApUserId());
        }
        return ResponseResult.okResult();
    }
}